package com.timebank.timecoin.service;

import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.timecoin.pojo.dto.TimeCoinTradeDTO;
import com.timebank.timecoin.pojo.entity.TimeCoinTrade;
import com.timebank.timecoin.pojo.vo.TimeCoinTradeVO;
import org.hyperledger.fabric.gateway.ContractException;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * @author shiliuyinzhen
 */
@Service
public interface TimeCoinTradeService {

    /**
     * 获取时间币支出交易列表
     * @return
     */
    List<TimeCoinTradeVO> getPayTradeByUserId(TimeCoinTradeDTO timeCoinTradeDTO);

    /**
     * 获取时间币收入交易列表
     * @return
     */
    List<TimeCoinTradeVO> getGetTradeByUserId(TimeCoinTradeDTO timeCoinTradeDTO);

    /**
     * 获取时间币所有交易列表
     * @return
     */
    List<TimeCoinTradeVO> getAllTradeByUserId(TimeCoinTradeDTO timeCoinTradeDTO);

    /**
     * 创建时间币交易
     * @param timeCoinTrade
     * @return
     */
    int createTrade(TimeCoinTrade timeCoinTrade);

    /**
     * 修改时间币交易状态
     * @param tradeId
     * @return
     */
    int updateTradeStatus(Long tradeId) throws ContractException, InterruptedException, TimeoutException;

    /**
     * 删除时间币交易
     * @param tradeIds
     * @return
     */
    int deleteTradeByIds(Long[] tradeIds);

    /**
     * 根据志愿服务Id和获得者Id删除时间币交易
     * @param volunteerId
     * @param getterId
     * @return
     */
    int deleteTradeByVolunteerIdAndGetterId(Long volunteerId, Long getterId);

    /**
     * 根据志愿服务Id支付时间币
     * @param volunteerId
     * @return
     */
    AjaxResult payTimeCoinByVolunteerId(Long volunteerId) throws ContractException, InterruptedException, TimeoutException;

    /**
     * 根据志愿服务Ids批量删除时间币交易
     * @param volunteerIds
     * @return
     */
    int deleteTradeByVolunteerIds(Long[] volunteerIds);

    /**
     * 根据用户Ids和志愿服务Id批量删除时间币交易
     * @param userIds
     * @return
     */
    int deleteTradeByUserIdsAndVolunteerId(Long[] userIds, Long volunteerId);

    /**
     * 条件查询时间币交易
     * @param timeCoinTrade
     * @return
     */
    List<TimeCoinTradeVO> getTradeByCondition(TimeCoinTrade timeCoinTrade);
}
